//
//  Address.m
//  OC_08_类的扩展
//
//  Created by wyx on 16/3/7.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "Address.h"
/** 类的延展
 *  注意类名()后为空
 *  声明私有化(隐藏的)属性和方法
 */
@interface Address ()
@property (nonatomic, retain) NSMutableDictionary *mDic;
@end
@implementation Address
- (void)dealloc
{
    [_mDic release];
    [super dealloc];
}
- (instancetype)init{
    self = [super init];
    if (self) {
        self.mDic = [NSMutableDictionary dictionary];
    }
    return self;
}

- (void)addContact:(Contact *)contact{
    NSString *group = [[contact.name substringToIndex:1] uppercaseString];
    NSMutableArray *arrOfCon = [self.mDic objectForKey:group];
    if (arrOfCon == nil) {
        arrOfCon = [NSMutableArray array];
        [arrOfCon addObject:contact];
        [self.mDic setObject:arrOfCon forKey:group];
    }
    else {
        [arrOfCon addObject:contact];
    }
    
    
}
@end
